#include <iostream>
#include <string>
#include <unordered_map>


using namespace std;
int main()
{
  // string str = "1#aaaaaa";
  string str ="kfdhtshmrw4nxg#f44ehlbn33ccto#mwfn2waebry#3qd1ubwyhcyuavuajb#vyecsycuzsmwp31ipzah#catatja3kaqbcss2th";
  int n = str.size();
  int left = 0,right = 0;
  int cnt1 = 0,cnt2 = 0;
  int ans = 0;
  while(right < n){
    if(right - left >= 16){
      if(str[left] >= '0' && str[left] <= '9'){
        cnt1--;
      }else if(str[left] == '#'){
        cnt2--;
      }
      left++;
    }
    if(str[right] >= '0' && str[right] <= '9'){
      cnt1++;
    }else if(str[right] == '#'){
      cnt2++;
    }
    int tmp1 = cnt1,tmp2 = cnt2;
    for(int i = left;right - i >= 7;i++){
      if(tmp1 != 0 && tmp2 != 0){
        ans++;
      }
      if(str[i] >= '0' && str[i] <= '9'){
        tmp1--;
      }else if(str[i] == '#'){
        tmp2--;
      }
    }
    right++;
  }
  cout << ans << endl;
  return 0;
}
#include <iostream>
using namespace std;
// (a + b + c) ^ 2 = 10455
// (a * b)*2 = 517 * 5 = 2565
// 
// 2 * a * b
// x * (x - 1) 
// a + b + c = 205;
// a * b = 5170;
// b * c = 5264;
// a * c = 3080;
int main()
{
  // 请在此输入您的代码
  cout << "55,94,56";
  return 0;
}
#include <iostream>
using namespace std;

// 1 0 0 0 (2,3)
// 
// 3 4 0 4 0
//  
// 2 0 0 0 1
int arr[10000][5000];
// int cnt[10004][10004];
long long ans = 0;
// 6 4 , 4 2 
int fun(int a, int b) {
	if (b == 0) return a;
	return fun(b, a % b);
}
void check(int x, int y) {
	if (arr[x][y] == 0) {
		arr[x][y] = 1;
	}
	else if (arr[x][y] == 1) {
		ans++;
		// cout << x <<' ' <<  y << endl;
		arr[x][y] = 2;
	}
}
int main()
{
	int n;  cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		if (a > c) {
			swap(a, c); swap(b, d);
		}
		int x = c - a, y = d - b;
		//int z = fun(abs(x), abs(y));
		int z = abs(fun(x, y));
		for (int i = 0;  abs(i * (x / z)) <= abs(x) && abs(i * (y / z)) <= abs(y); i++) {
			// cout << a + i * (x / z) << "," << b + i * (y / z) << ' ';
			check(a + i * (x / z), b + i * (y / z));
		
		}
		// cout << endl;
	}
	cout << ans << endl;
	return 0;
}



#include <iostream>
int arr[100005];
int n,m;  
using namespace std;

bool fun(int mid){
  int i = 1;
  int cnt = 0;
  while(i <= n){
    cnt += max(0,(arr[i] - arr[i - 1] - 1) / mid) ;
    if(cnt > m + 1){
      return false;
    }
    i++;
  }
  // out << mid <<' ' << cnt  << endl;
  return true;
}

int main()
{
  cin >> n >> m;
  for(int i = 1;i <= n;i++){
    cin >> arr[i];
  }
  int left = 1,right = 100010;
  while(left <= right){
    int mid = (left + right) / 2;
    // cout << mid <<' ';
    if(fun(mid)){
      right = mid - 1;
    }else{
      left = mid + 1;
    }
  }
  cout << left << endl;
  return 0;
}
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
  int n,m;
  string s1,s2;
  cin >> n >> m;
  cin >> s1 >> s2;
  sort(s2.begin(),s2.end());
  string ans;
  int i = 0,j = 0;
  while(i < n && j < m){
    if(s1[i] <= s2[j]){
      ans.push_back(s1[i++]);
    }else{
      ans.push_back(s2[j++]);
    }
  }
  while(i < n){
    ans.push_back(s1[i++]);
  }
  while(j < m){
    ans.push_back(s2[j++]);
  }
  // cout << s2 << endl;
  cout << ans << endl;
  return 0;
}